x86 vmx: Ensure debug-mode intercept for int3 and debug exceptions are
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 13 May 2009 09:39:44 +0000 (10:39 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 13 May 2009 09:39:44 +0000 (10:39 +0100)
reinstated when resetting EXCEPTION_BIRTMAP entry in VMCS after
exiting real mode.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/vmx/vmcs.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vmx/vmx.h

index c86b55e6f73c34cf32e2b77f54388dc3075fd36d..aea69c7b94c01dd9622ba15476b2bf4f66255efd 100644 (file)
@@ -912,18 +912,8 @@ void vmx_do_resume(struct vcpu *v)
     debug_state = v->domain->debugger_attached;
     if ( unlikely(v->arch.hvm_vcpu.debug_state_latch != debug_state) )
     {
-        unsigned long intercepts = __vmread(EXCEPTION_BITMAP);
-        unsigned long mask = 1u << TRAP_int3;
-
-        if ( !cpu_has_monitor_trap_flag )
-            mask |= 1u << TRAP_debug;
-
         v->arch.hvm_vcpu.debug_state_latch = debug_state;
-        if ( debug_state )
-            intercepts |= mask;
-        else
-            intercepts &= ~mask;
-        __vmwrite(EXCEPTION_BITMAP, intercepts);
+        vmx_update_debug_state(v);
     }
 
     hvm_do_resume(v);
index ff200cb5f1da9f21692379431705b352ad4d9b23..64d9f39c89f1b948bd321e64f3724bd3b75f2660 100644 (file)
@@ -1035,6 +1035,24 @@ static void vmx_update_host_cr3(struct vcpu *v)
     vmx_vmcs_exit(v);
 }
 
+void vmx_update_debug_state(struct vcpu *v)
+{
+    unsigned long intercepts, mask;
+
+    ASSERT(v == current);
+
+    mask = 1u << TRAP_int3;
+    if ( !cpu_has_monitor_trap_flag )
+        mask |= 1u << TRAP_debug;
+
+    intercepts = __vmread(EXCEPTION_BITMAP);
+    if ( v->arch.hvm_vcpu.debug_state_latch )
+        intercepts |= mask;
+    else
+        intercepts &= ~mask;
+    __vmwrite(EXCEPTION_BITMAP, intercepts);
+}
+
 static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
 {
     vmx_vmcs_enter(v);
@@ -1107,6 +1125,7 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
                           | (paging_mode_hap(v->domain) ?
                              0 : (1U << TRAP_page_fault))
                           | (1U << TRAP_no_device));
+                vmx_update_debug_state(v);
             }
         }
 
index 6fd989431dad21a8171065ead27894bf3c76ddba..97cf7635ff70d37a333e799932a1eaf410d0fdf3 100644 (file)
@@ -60,6 +60,7 @@ void vmx_intr_assist(void);
 void vmx_do_resume(struct vcpu *);
 void vmx_vlapic_msr_changed(struct vcpu *v);
 void vmx_realmode(struct cpu_user_regs *regs);
+void vmx_update_debug_state(struct vcpu *v);
 
 /*
  * Exit Reasons